package com.example.service;

import com.example.entity.MapQuestion;
import com.example.mapper.MapQuestionsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
关卡任务业务处理
 */
@Service
public class MapQuestionsService {

    @Resource
    private MapQuestionsMapper mapquestionsMapper;

    public void add(MapQuestion mapquestions) {
        mapquestionsMapper.insert(mapquestions);
    }

    public void deleteById(Integer id) {
        mapquestionsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(MapQuestion mapquestions) {
        mapquestionsMapper.updateById(mapquestions);
    }

    public MapQuestion selectById(Integer id) {
        return mapquestionsMapper.selectById(id);
    }

    public List<MapQuestion> selectAll(MapQuestion mapquestions) {
        return mapquestionsMapper.selectAll(mapquestions);
    }

    public PageInfo<MapQuestion> selectPage(MapQuestion mapquestions, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MapQuestion> questionsList = mapquestionsMapper.selectAll(mapquestions);
        return PageInfo.of(questionsList);
    }
}
